<template>
	<view>
		<textarea name="" id="" cols="30" rows="10" v-model="content"></textarea>
		<button type="primary" @click="handleAdd">确定</button>
	</view>
</template>

<script>
import { request } from '../../utils';
	export default {
		data() {
			return {
				content: '',
				uid: ''
			};
		},
		methods: {
			async handleAdd() {
				const data = {
					"uid": +this.uid,
					"id": Math.random().toString().slice(2),
					"nickname": uni.getStorageSync('nickname'),
					"avator": uni.getStorageSync('avator'),
					"datetime": new Date().toLocaleString(),
					"content": this.content
				}
				const resp = await request({
					url: 'http://localhost:3000/messageList',
					method: 'post',
					data
				});
				// 返回上一夜
				uni.navigateBack()
			}
		},
		onLoad({ uid }) {
			this.uid = uid
		}
	}
</script>

<style lang="scss" scoped>
	textarea {
		width: 100%;
		height: 50vh;
	}
</style>